package com.kuang.demo.controller.wx;

import com.kuang.demo.bean.BaseRespVo;
import com.kuang.demo.bo.wx.WxclearHistoryBO;
import com.kuang.demo.mapper.wx.WxKeyWordMapper;
import com.kuang.demo.service.wx.WxKeyWordService;
import com.kuang.demo.vo.wx.WxQuerySearchIndex;
import com.kuang.demo.vo.wx.WxSearchHelperVO;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by 郭浩 on 2020/11/5 20:34
 */
@RestController
@RequestMapping("wx/search")
public class WxKeyWordController {

    @Autowired
    WxKeyWordService wxKeyWordService;

    @GetMapping("index")
    public BaseRespVo searchIndex(){
        WxQuerySearchIndex wxQuerySearchIndex = wxKeyWordService.getSearchIndex();
        return BaseRespVo.ok(wxQuerySearchIndex);
    }

    @GetMapping("helper")
    public BaseRespVo searchHelper(String keyword){
        WxSearchHelperVO wxSearchHelperVO = wxKeyWordService.searchHelp(keyword);
        return BaseRespVo.ok(wxSearchHelperVO);
    }

    @PostMapping("clearhistory")
    public BaseRespVo clearHistory(@RequestBody WxclearHistoryBO wxclearHistoryBO){
        wxKeyWordService.clearHisttory(wxclearHistoryBO);
        return BaseRespVo.ok();
    }
}
